using NUnit.Framework;
using ProjectEuler.Core.Helpers;

namespace ProjectEuler.Core
{
    public class Problem15 : IProjectEulerProblem
    {
        public int Number
        {
            get { return 15; }
        }

        public string Description
        {
            get { return "How many routes are there through a 20x20 grid?"; }
        }

        public string Answer
        {
            // multiply 2*row - overlay the grid of size n on pascals triangle as a diamond
            // so the answers will be row 2,4,6,8,10,etc and column 2,3,4,5,6,etc
            get { return MathHelper.PascalsTriangleGetEntry(2*20, 20).ToString(); }
        }
    }

    [TestFixture]
    public class Problem15Tests : Problem15
    {
        [Test]
        public void There_should_be_6_routes_in_a_2x2_grid()
        {
            Assert.AreEqual(6, MathHelper.PascalsTriangleGetEntry(2 * 2, 2));
        }

        [Test]
        public void There_should_be_20_routes_in_a_3x3_grid()
        {
            Assert.AreEqual(20, MathHelper.PascalsTriangleGetEntry(2 * 3, 3));
        }
    }
}